package com.yinhai.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yinhai.activity.R;
import com.yinhai.model.CloudNote;

public class CloudNotePopAdapter extends BaseAdapter {

	private Context ctx;
	private List<CloudNote> list;
	private LayoutInflater inflater;

	public CloudNotePopAdapter(Context context, List<CloudNote> list) {
		this.ctx = context;
		this.list = list;
		this.inflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.popcloudnote_list_item, null);
			holder = new ViewHolder();
			holder.title = (TextView) convertView
					.findViewById(R.id.title);
			holder.uuid = (TextView) convertView
					.findViewById(R.id.uuid);
			holder.pid = (TextView) convertView
			.findViewById(R.id.pid);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		CloudNote cloudNote = list.get(position);
		
		holder.title.setText(cloudNote.getNote());
		holder.uuid.setText(cloudNote.getUuid());
		holder.pid.setText(cloudNote.getPid());

		return convertView;
	}

	public static class ViewHolder {
		TextView title;
		TextView uuid;
		TextView pid;
		public TextView getTitle() {
			return title;
		}
		public void setTitle(TextView title) {
			this.title = title;
		}
		public TextView getUuid() {
			return uuid;
		}
		public void setUuid(TextView uuid) {
			this.uuid = uuid;
		}
		public TextView getPid() {
			return pid;
		}
		public void setPid(TextView pid) {
			this.pid = pid;
		}
	}

}
